package com.koala.learn.json.inner;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;

import java.io.IOException;

/**
 * 1. 获得json内部对象
 * 1.1 @JsonProperty("car.brand") 不能获得
 * 2. JsonNode 学习
 *
 * @author yantingrui
 * @date 2022/7/25   17:06
 */
public class Start {

    private final ObjectMapper mapper = new ObjectMapper();

    public static void main(String[] args) throws IOException {
        Person person = new Person("理想", new Car("理想汽车"));
        ObjectMapper mapper = new ObjectMapper();
        String str = mapper.writeValueAsString(person);
        Data2 data2 = mapper.readValue(str, Data2.class);
        System.out.println(data2);
        //JsonNode value = data2.getCar().findValue("1");
        //System.out.println(value);
        //{"name":"2","car":{"brand":"1"}}
        //JsonNode jsonNode = mapper.readTree(str);
        //JsonNode brand = jsonNode.findValue("brand");
        //System.out.println(brand);
    }

    /**
     *
     */
    @Test
    public void test35() {

    }
}
